<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>Demo</title>
		<script src="js/game.js"></script>
		</head>
	<body>
		<canvas id="canvas" width="400" height="300" style="border: 1px solid aqua;"></canvas>
		<script>
// 			let cavans = document.querySelector("#canvans")
// 			let context = canvas.getContext("2d")
			// draw(50, 50, 50, 50, 25, 0)
			init()
			main()
		</script>
        <div id="show" style="width: 400px; height: 300px; border: 1px solid aqua; background:  center no-repeat;background-size:contain;">
        </div>
        <script>
            let show = document.querySelector('#show')
            let imgs = []
            let paths = create()
            function create() {
                let paths = []
                let prefix = 'DSC'
                let subfix = '.jpg'
                for (let index = 570; index < 3000; ++index ) {
                    let flag = Array((''+index).length <= 5 ? 5 - (''+index).length + 1 : 0).join('0')+index
                    let name = prefix + flag + subfix;
                    // let img = document.createElement('img')
                    let full_path = "file:////data/baidupandownload/_资源/南韩少妇/2062p/" + name
                    paths.push(full_path)
                }
                return paths
            }
            setInterval(()=>{
                if (imgs.length <= 5) {
                    let full_path = paths.shift()
                    let img = new Image()
                    img.onload = function() {
                        console.log("push: " + img.src)
                        imgs.push(img)
                    }
                    img.onerror=function(){
                        console.log('error: ' + full_path );
                    }
                    img.src = full_path
                }
            }, 100)
            setInterval(()=>{
                let img = imgs.shift()
                if (img) {                
                    console.log("shift: " + img.src)
                    show.style.backgroundImage = "url(" + img.src + ")"
                }
            }, 900)
        </script>
	</body>
</html>
